home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / dns / update.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  5KB  |  155 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. import dns.message as dns
  5. import dns.name as dns
  6. import dns.opcode as dns
  7. import dns.rdata as dns
  8. import dns.rdataclass as dns
  9. import dns.rdataset as dns
  10.  
  11. class Update(dns.message.Message):
  12.     
  13.     def __init__(self, zone, rdclass = dns.rdataclass.IN, keyring = None, keyname = None):
  14.         super(Update, self).__init__()
  15.         self.flags |= dns.opcode.to_flags(dns.opcode.UPDATE)
  16.         if isinstance(zone, (str, unicode)):
  17.             zone = dns.name.from_text(zone)
  18.         
  19.         self.origin = zone
  20.         if isinstance(rdclass, str):
  21.             rdclass = dns.rdataclass.from_text(rdclass)
  22.         
  23.         self.zone_rdclass = rdclass
  24.         self.find_rrset(self.question, self.origin, rdclass, dns.rdatatype.SOA, create = True, force_unique = True)
  25.         if keyring is not None:
  26.             self.use_tsig(keyring, keyname)
  27.         
  28.  
  29.     
  30.     def _add_rr(self, name, ttl, rd, deleting = None, section = None):
  31.         if section is None:
  32.             section = self.authority
  33.         
  34.         covers = rd.covers()
  35.         rrset = self.find_rrset(section, name, self.zone_rdclass, rd.rdtype, covers, deleting, True, True)
  36.         rrset.add(rd, ttl)
  37.  
  38.     
  39.     def _add(self, replace, section, name, *args):
  40.         if isinstance(name, (str, unicode)):
  41.             name = dns.name.from_text(name, None)
  42.         
  43.         if isinstance(args[0], dns.rdataset.Rdataset):
  44.             for rds in args:
  45.                 if replace:
  46.                     self.delete(name, rds.rdtype)
  47.                 
  48.                 for rd in rds:
  49.                     self._add_rr(name, rds.ttl, rd, section = section)
  50.                 
  51.             
  52.         else:
  53.             args = list(args)
  54.             ttl = int(args.pop(0))
  55.             if isinstance(args[0], dns.rdata.Rdata):
  56.                 if replace:
  57.                     self.delete(name, args[0].rdtype)
  58.                 
  59.                 for rd in args:
  60.                     self._add_rr(name, ttl, rd, section = section)
  61.                 
  62.             else:
  63.                 rdtype = args.pop(0)
  64.                 if isinstance(rdtype, str):
  65.                     rdtype = dns.rdatatype.from_text(rdtype)
  66.                 
  67.                 if replace:
  68.                     self.delete(name, rdtype)
  69.                 
  70.                 for s in args:
  71.                     rd = dns.rdata.from_text(self.zone_rdclass, rdtype, s, self.origin)
  72.                     self._add_rr(name, ttl, rd, section = section)
  73.                 
  74.  
  75.     
  76.     def add(self, name, *args):
  77.         self._add(False, self.authority, name, *args)
  78.  
  79.     
  80.     def delete(self, name, *args):
  81.         if isinstance(name, (str, unicode)):
  82.             name = dns.name.from_text(name, None)
  83.         
  84.         if len(args) == 0:
  85.             rrset = self.find_rrset(self.authority, name, dns.rdataclass.ANY, dns.rdatatype.ANY, dns.rdatatype.NONE, dns.rdatatype.ANY, True, True)
  86.         elif isinstance(args[0], dns.rdataset.Rdataset):
  87.             for rds in args:
  88.                 for rd in rds:
  89.                     self._add_rr(name, 0, rd, dns.rdataclass.NONE)
  90.                 
  91.             
  92.         else:
  93.             args = list(args)
  94.             if isinstance(args[0], dns.rdata.Rdata):
  95.                 for rd in args:
  96.                     self._add_rr(name, 0, rd, dns.rdataclass.NONE)
  97.                 
  98.             else:
  99.                 rdtype = args.pop(0)
  100.                 if isinstance(rdtype, str):
  101.                     rdtype = dns.rdatatype.from_text(rdtype)
  102.                 
  103.                 if len(args) == 0:
  104.                     rrset = self.find_rrset(self.authority, name, self.zone_rdclass, rdtype, dns.rdatatype.NONE, dns.rdataclass.ANY, True, True)
  105.                 else:
  106.                     for s in args:
  107.                         rd = dns.rdata.from_text(self.zone_rdclass, rdtype, s, self.origin)
  108.                         self._add_rr(name, 0, rd, dns.rdataclass.NONE)
  109.                     
  110.  
  111.     
  112.     def replace(self, name, *args):
  113.         self._add(True, self.authority, name, *args)
  114.  
  115.     
  116.     def present(self, name, *args):
  117.         if isinstance(name, (str, unicode)):
  118.             name = dns.name.from_text(name, None)
  119.         
  120.         if len(args) == 0:
  121.             rrset = self.find_rrset(self.answer, name, dns.rdataclass.ANY, dns.rdatatype.ANY, dns.rdatatype.NONE, None, True, True)
  122.         elif isinstance(args[0], dns.rdataset.Rdataset) and isinstance(args[0], dns.rdata.Rdata) or len(args) > 1:
  123.             if len(args) > 1:
  124.                 args = list(args)
  125.                 args.insert(0, 0)
  126.             
  127.             self._add(False, self.answer, name, *args)
  128.         else:
  129.             rdtype = args[0]
  130.             if isinstance(rdtype, str):
  131.                 rdtype = dns.rdatatype.from_text(rdtype)
  132.             
  133.             rrset = self.find_rrset(self.answer, name, dns.rdataclass.ANY, rdtype, dns.rdatatype.NONE, None, True, True)
  134.  
  135.     
  136.     def absent(self, name, rdtype = None):
  137.         if isinstance(name, (str, unicode)):
  138.             name = dns.name.from_text(name, None)
  139.         
  140.         if rdtype is None:
  141.             rrset = self.find_rrset(self.answer, name, dns.rdataclass.NONE, dns.rdatatype.ANY, dns.rdatatype.NONE, None, True, True)
  142.         elif isinstance(rdtype, str):
  143.             rdtype = dns.rdatatype.from_text(rdtype)
  144.         
  145.         rrset = self.find_rrset(self.answer, name, dns.rdataclass.NONE, rdtype, dns.rdatatype.NONE, None, True, True)
  146.  
  147.     
  148.     def to_wire(self, origin = None, max_size = 65535):
  149.         if origin is None:
  150.             origin = self.origin
  151.         
  152.         return super(Update, self).to_wire(origin, max_size)
  153.  
  154.  
  155.